package com.weaver.drools.common.utils;

import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 
 *  @project: Absu_Blog
 *  @author: zhouxinlei
 *  @time：2018年8月9日
 *  @version：ver 1.1
 */
public class LLog {
    private static final Logger logger = LoggerFactory.getLogger(LLog.class);
    private static final Map<String, Logger> logs = new HashMap<String, Logger>();

    @SuppressWarnings({ "unused", "rawtypes" })
	public static Logger get(Class<?> clazz) {
        String name = clazz.getName();
        Logger l = (Logger) logs.get(name);
        if (l == null) {
            Map arg2 = logs;
            synchronized (logs) {
                l = (Logger) logs.get(name);
                if (l == null) {
                    l = LoggerFactory.getLogger(clazz);
                    logs.put(name, l);
                }
            }
        }

        return l;
    }

    public static void error(Throwable e) {
        logger.error("LLog Error:", e);
    }

    public static void error(String s, Throwable e) {
        logger.error(s, e);
    }

    public static void error(String s) {
        logger.error(s);
    }

    public static void info(String s) {
        logger.info(s);
    }

    public static void debug(String s) {
        logger.debug(s);
    }

    public static void warn(String s) {
        logger.warn(s);
    }

    public static boolean isDebugEnabled() {
        return logger.isDebugEnabled();
    }

    public static boolean isWarnEnabled() {
        return logger.isWarnEnabled();
    }

    public static boolean isInfoEnabled() {
        return logger.isInfoEnabled();
    }

    public static boolean isErrorEnabled() {
        return logger.isErrorEnabled();
    }
}